package com.yunxiao.cloud.web.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @description: WhhDataSource
 * 基于aop切换数据源
 * @author: yunxiao
 * @date: 2020/1/20 9:30
 * @version: V1.0
 **/
public class WhhDataSource extends AbstractRoutingDataSource {

    private static final Logger logger = LoggerFactory.getLogger(WhhDataSource.class);


    @Override
    protected Object determineCurrentLookupKey() {
        //基于aop切换数据源
        logger.info("WhhDataSource 切换数据源:{}" , DataSourceHolder.getDataSource());

        return DataSourceHolder.getDataSource();
    }
}
